<template>
	<view>

		<view class="list_box">

			<view @click="to(item)" class="list_info" v-for="(item,index) in list" :key="index">

				<view class="f_s sku_box">
					<view class="f_left ">
						<view class="f_c">
							<view class="l_name">{{item.nickname}}</view>
							<view class="l_mobile">{{item.mobile}}</view>
							<view class="sku" v-if="item.groups">{{item.groups.name}}</view>
						</view>
						<view class="plot">
							<view ><text v-if="item.plot">{{item.plot.name}}</text><text v-if="item.floor">{{item.floor.name}}</text><text v-if="item.layer">{{item.layer.name}}</text><text v-if="item.room">{{item.room.name}}</text></view>
						</view>
					</view>
					
					<view v-if="type==1">
						<text class="iconfont iconfanhui t-180 gray_font"></text>
					</view>
					
					
				</view>

				<view class="f_s time_box">
					<view class="time">{{item.createtime}} 申请</view>
					<view :class="['status',item.status==1?'st_hui':'',item.status==3?'st_red':'']">{{item.status_text}}</view>
					<view v-if="false" class="del_box" @click="del(item)">删除记录</view>
				</view>
			</view>

		</view>

		<view style="height: 100rpx;" v-if="type==1"></view>

		<view class="bot_box" v-if="type==1">
			<view class="btn" @click="add()">+ 新增认证</view>
		</view>

		<view v-if="show" class="bitmap">
			<image :src="none" mode="widthFix"></image>
			<view>亲！暂无房屋信息</view>
		</view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				total: 0,
				params: {
					page: 1,
					status: 0,
					token: '',
					status:''
				},
				show: false,
				type:1,
				none:''
			}
		},
		onShow() {
			this.getList();
		},
		onLoad(e) {
			this.none=this.$imgUrl+'assets/img/none_fw.png';
		   if(e.type){
			   this.type=e.type;
			   this.params.status=2;
		   }
		},
		methods: {
			to(e){
				
				if(this.type==1){
					uni.navigateTo({
						url:'/pages/user/fwinfo?id='+e.id
					})
				}
				if(this.type==2){
					uni.setStorageSync('address', JSON.stringify(e));
					this.$back();
				}
				
			},
			add() {
				uni.navigateTo({
					url: '/pages/new/form?type=3'
				});
			},
			del(e) {

				let params = {
					token: uni.getStorageSync('userToken'),
					id: e.id
				};
				let _ = this;
				_.$showModal('确认删除?', () => {
					_.$post(_.$api.aduitDel, params, res => {
						let data = res.data;

						if (data.code == 1) {
							_.$Toast(data.msg);
							_.getList();
						} else {
							_.$Toast(data.msg);
						}
					});
				});
			},
			setShow() {
				if (this.total < 1) {
					this.show = true;
				} else {
					this.show = false;
				}
			},
			getList() {
				this.params.page = 1;
				this.params.token = uni.getStorageSync('userToken');
				this.$get(this.$api.aduitList, this.params, res => {
					let {
						data,
						code
					} = res.data;
					if (code == 1) {
						this.list = data.data;
						this.total = data.total;
						this.setShow();
					}
				});
			}
		},
		
		onReachBottom() {
			if (this.total <= this.list.length) return;

			this.params.page++;
			this.params.token = uni.getStorageSync('userToken');
			this.$get(this.$api.aduitList, this.params, res => {
				let data = res.data;

				if (data.code == 1) {

					this.list = this.list.concat(data.data.data);
					this.total = data.data.total;
				}
			});
		}
	}
</script>

<style lang="scss" scoped>
	.bot_box {
		color: white;
		background-color: #E34305;
		font-size: 28rpx;
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		text-align: center;
		height: 100rpx;
		line-height: 100rpx;
	}

	.list_box {
		box-sizing: border-box;
		padding: 25rpx;
	}

	.list_info {
		border-radius: 15rpx;
		background-color: white;
		box-sizing: border-box;
		padding: 20rpx;
		margin-bottom: 30rpx;
	}

    .plot{
	box-sizing: border-box;
	padding: 20rpx 0 0 0;
     }

	.l_name {
		font-weight: bold;
		font-size: 32rpx;
	}

   .l_mobile{
	   font-size: 26rpx;
	   margin: 0 30rpx;
   }

	.f_s {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
	.f_c{
		display: flex;
		align-items: center;
	}

	.status {
		color: #E9911F;
	}

	.sku_box {
		box-sizing: border-box;
		padding: 20rpx 0;
		border-bottom: 1rpx solid #eee;
	}

	.sku {
		color: white;
		background-color: #EB8308;
		font-size: 25rpx;
		box-sizing: border-box;
		padding: 5rpx 20rpx;
		border-radius: 15rpx;
	}

	.time_box {
		box-sizing: border-box;
		padding: 20rpx 0 0 0;
	}

	.time {
		color: #828282;
		font-size: 24rpx;
	}

	.del_box {
		box-sizing: border-box;
		padding: 10rpx 20rpx;
		border-radius: 8rpx;
		font-size: 26rpx;
		border: 1rpx solid #D8D8D8;
	}
	.f_left{
		width: 85%;
	}
	.st_hui{
		color: #80807E;
	}
	.st_red{
		color: red;
	}
	
	.bitmap{
		text-align: center;
		image{
			width: 60%;
		}
	}
</style>